package com.mrx.example.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.mrx.example.model.Emp;

public interface EmpMapper {

    @Select("SELECT * FROM t_emps")
    List<Emp> findAllEmps();

    @Select("SELECT * FROM t_emps WHERE id = #{id}")
    Emp findEmpById(String id);

    @Select("SELECT * FROM t_emps WHERE deptid = #{dId}")
    List<Emp> findEmpsByDeptId(Integer dId);

    @Insert("INSERT INTO t_emps(id,name,sex,birth,salary,deptId) "
            + "VALUES(#{id},#{name},#{sex},#{birth},#{salary},#{deptId})")
    Boolean addEmp(Emp emp);

    @Update("UPDATE t_emps SET name=#{name}, sex=#{sex}, birth=#{birth}, "
            + "salary=#{salary}, deptId=#{deptId} WHERE id=#{id}")
    Boolean updateEmp(Emp emp);

    @Delete("DELETE FROM t_emps WHERE id = #{id}")
    Boolean delEmpById(String id);
}
